package com.szh.publisher.controller;

import com.szh.publisher.mq.MessageMq;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.messaging.support.MessageBuilder;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;


/**
 * 基于spring-cloud-starter-stream-rabbit 通过
 * @Output 发送（输出）
 */
@RestController
@RequestMapping("/stream")
@Slf4j
@EnableBinding({MessageMq.class})
public class V2 {

    @Resource
    MessageMq userMq;

    @GetMapping("/mq")
    public void testSend(String str){
        userMq.output()
                .send(MessageBuilder.withPayload(str)
                        .setHeader("type","modifyOrg")
                        .build());
    }
}
